package alo.p19;

/**
 * @ClassName LongestIncreasingSequence
 * @Description 最长递增子序列(不一定连续)
 * @Author Fanxc
 * @DATE 2021/3/15 20:40
 * @Version 1.0
 */
public class LongestIncreasingSequence {
    int[] LISTable=new int[1024];
    int longestIncreasingSequence(int[] A,int n){
        int max=0;
        for (int i = 0; i < n; i++) {
            LISTable[i]=1;
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < i; j++) {
                if (A[i]>A[j]&&LISTable[i]<LISTable[j]+1){
                    LISTable[i]=LISTable[j]+1;
                }
            }
        }
        for (int i = 0; i < n; i++) {
            if (max<LISTable[i]){
                max= LISTable[i];
            }
        }
        return max;
    }
}
